#ifndef RFID_H
#define RFID_H

#include <QObject>
#include <QTimer>
#include <QDebug>

#ifndef __cplusplus
extern "C"
{
#endif

#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <termios.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>

#define USART1 "/dev/ttySAC1"

#ifndef __cplusplus
}
#endif

class Rfid : public QObject
{
    Q_OBJECT
public:
    explicit Rfid(QObject *parent = nullptr);
    void startListen();
    void stopListen();

signals:
    void readID(QString id);

private:
    QTimer *timer;
    int timer_refresh;
    int init_tty(int fd);
    unsigned char calc_BCC(unsigned char*SerBfr,int len);
    int piccRequest(int fd);
    int piccAnticoll(int fd);
    void readCardId(void);

private slots:
    void timeout();

};

#endif // RFID_H
